package org.database.config;

import lombok.RequiredArgsConstructor;
import org.database.attribute.YmlStorageAttribute;
import org.database.service.StorageAbstract;
import org.database.service.impl.YmlStorage;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * BeanInit
 *
 * @author grl
 * @date 2024/1/4
 */
@Configuration
@RequiredArgsConstructor
public class DataBaseBeanInitConfiguration {

    private final YmlStorageAttribute ymlStorageAttribute;

    @Bean
    @ConditionalOnMissingBean(value = StorageAbstract.class)
    public StorageAbstract getStorage(){
        return new YmlStorage(ymlStorageAttribute);
    }
}
